package com.dfs.parent.common.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;


public class DfsMetaObjectHandler implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
       // this.setInsertFieldValByName("version", 0, metaObject);
//        this.setInsertFieldValByName("delFlag", 1, metaObject);
//        this.setInsertFieldValByName("gmtCreate", new Date(), metaObject);
//        this.setInsertFieldValByName("gmtModified", new Date(), metaObject);
// gmt_create
        this.strictInsertFill(metaObject, "gmtCreate", Date.class,new Date()); // 起始版本 3.3.3(推荐)
        this.strictInsertFill(metaObject, "createdTime", Date.class,new Date()); // 起始版本 3.3.3(推荐)
        this.strictInsertFill(metaObject, "delFlag", Integer.class,0); // 起始版本 3.3.3(推荐)
    }

    @Override
    public void updateFill(MetaObject metaObject) {
//        this.setUpdateFieldValByName("gmtModified", new Date(), metaObject);
        this.strictUpdateFill(metaObject, "modifiedTime", Date.class, new Date()); // 起始版本 3.3.3(推荐)
        this.strictUpdateFill(metaObject, "gmtModified", Date.class, new Date()); // 起始版本 3.3.3(推荐)

    }

}
